home *** CD-ROM | disk | FTP | other *** search
- Path: ionews.ionet.net!usenet
- From: David Shaffer <dshaffer@traffic.jam.net>
- Newsgroups: comp.lang.c
- Subject: printf changing a pointer
- Date: Fri, 02 Feb 1996 21:41:13 -0600
- Organization: Shaffer Systems
- Message-ID: <3112D959.58AD6E2A@traffic.jam.net>
- NNTP-Posting-Host: osip20.ionet.net
- Mime-Version: 1.0
- Content-Type: multipart/mixed;
- boundary="---------------------------207030344915297696601643038769"
- X-Mailer: Mozilla 2.0b4 (X11; I; Linux 1.2.8 i486)
-
- This is a multi-part message in MIME format.
-
- -----------------------------207030344915297696601643038769
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
-
- I don't understand the following...
-
- --
- David Shaffer
- http://traffic.jam.net/~dshaffer
-
- -----------------------------207030344915297696601643038769
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- Content-Disposition: inline; filename="prog1.out"
-
- *** this is the output
- initializing data base... prog1.bin to hash file hash.dat...
- initializing hash table entries... depth of this table is 0
- creating a bucket at file location 0...
- creating a bucket at file location 1200...
- creating a bucket at file location 2400...
- creating a bucket at file location 3600...
- creating a bucket at file location 4800...
- creating a bucket at file location 6000...
- creating a bucket at file location 7200...
-
- *** this is what gdb shows
- 45 record = (RECORD*)get_entry (maintable,"WASH", hashfile, binaryfile);
- (gdb)
- 46 printf("%s\n",record->city);
- (gdb) print record
- $1 = (RECORD *) 0xbffffbc8
- (gdb) print *record
- $2 = {city = "WASH", date = "01/17", time = "1745", air_temp = 0,
- wind_speed = 0, wind_direction = 0, rain_amount = 0}
- (gdb) s
-
- 47 }
- (gdb) print *record
- $3 = {city = "\017\021\000", date = "\226\020\000\000ñ", time = "√ ┐5",
- air_temp = 0, wind_speed = 0, wind_direction = 0, rain_amount = 0}
-
- why is record changed by a printf statement?
-
- -----------------------------207030344915297696601643038769--
-
-